package cn.edu.stu.syllabus.utils;

import android.os.Build;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.orhanobut.logger.Logger;

import cn.edu.stu.syllabus.R;
import cn.edu.stu.syllabus.application.SyllabusApplication;
import cn.edu.stu.syllabus.base.BaseActivity;

/**
 * Created by liyujie on 2017/4/20.
 */

public class RecyclerPaddingUtils {

    public static void fitRecyclerViewPadding(BaseActivity activity, RecyclerView recyclerView) {

        int top = recyclerView.getPaddingTop();
        int left = recyclerView.getPaddingLeft();
        int right = recyclerView.getRight();
        int bottom = recyclerView.getBottom();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            top = top + activity.getStatusBarHeight() - 1;
        } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
            top = top + activity.getStatusBarHeight() - 1;
        } else {
            top = top - 1;
        }

        top = top + activity.getResources().getDimensionPixelSize(R.dimen.toolbarHeight);

        recyclerView.setPadding(left, top, right, bottom);
    }
}
